
import 'package:baselib/base/base_service.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

/**
 * 基础逻辑处理类
 */
abstract class BaseViewModel<T extends BaseService> extends GetxController{
  //泛型服务层
  T apiService;

  BaseViewModel(){
    createService();
  }
  //创建网络层
  T createService();

  @override
  void onInit() {
    print('onInit');
    super.onInit();
    //Loading, Success, Error handle with 1 line of code
  }

  @override
  void onReady() {
    print('onReady');
    super.onReady();
  }

  @override
  void onClose() {
    print('onClose');
    super.onClose();
  }

  @override
  void didChangeMetrics() {
    print('didChangeMetrics');
  }

  @override
  void didChangePlatformBrightness() {
    print('didChangePlatformBrightness');
  }

  @override
  Future<bool> didPushRoute(String route) {
    print('didPushRoute route=$route');
  }

  @override
  Future<bool> didPopRoute() {
    print('didPopRoute');
  }

  @override
  void onDetached() {
    print('onDetached');
  }

  @override
  void onInactive() {
    print('onInative');
  }

  @override
  void onPaused() {
    print('onPaused');
  }

  @override
  void onResumed() {
    print('onResumed');
  }

  @override
  void update([List<Object> ids, bool condition = true]) {
    // TODO: implement update
    print('update');
    super.update(ids, condition);
  }

}